package com.kx.yooli.kx.wechat.controller.index;

import com.kx.yooli.kx.wechat.po.result.AjaxResult;
import com.kx.yooli.kx.wechat.service.index.IndexService;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author sqwen
 * @date 2024-06-09
 *
 *
 */
@RestController
@RequestMapping("/api/index/")
public class IndexController {
    private final IndexService indexService;

    public IndexController(IndexService indexService) {
        this.indexService = indexService;
    }

    /**
     * 根据手机号去查询所有的数据
     *
     */
    @RequestMapping(value ="selectBillCount",method = RequestMethod.POST)
    public AjaxResult selectBillCount(@RequestParam("mobile")String mobile){
        Assert.notNull(mobile,"参数为空！");
        return  AjaxResult.success(indexService.selectBill(mobile));
    }
    @RequestMapping(value ="selectCreditCount",method = RequestMethod.POST)
    public AjaxResult selectCreditCount(@RequestParam("mobile")String mobile){
        Assert.notNull(mobile,"参数为空！");
        return AjaxResult.success(indexService.selectCredit(mobile));
    }
    @RequestMapping(value = "selectBankCount",method = RequestMethod.POST)
    public AjaxResult selectBankCount(@RequestParam("mobile")String mobile){
        Assert.notNull(mobile,"参数为空！");
        return AjaxResult.success(indexService.selectBinding(mobile));
    }
    @RequestMapping(value ="selectUserCount",method = RequestMethod.POST)
    public AjaxResult selectUserCount(@RequestParam("mobile")String mobile){
        Assert.notNull(mobile,"参数为空！");
        return AjaxResult.success(indexService.selectUser(mobile));
    }
    @RequestMapping(value = "selectRepaymentInfo",method = RequestMethod.POST)
    public AjaxResult selectRepaymentInfo(@RequestParam("mobile")String mobile){
        Assert.notNull(mobile,"参数为空！");
        return AjaxResult.success(indexService.selectByListRepayment(mobile));
    }
    @RequestMapping(value = "selectRepaymentInfoDetail",method = RequestMethod.POST)
    public AjaxResult selectRepaymentInfoDetail(@RequestParam("loanNo")String loanNo){
        Assert.notNull(loanNo,"参数为空！");
        return AjaxResult.success(indexService.selectByListInfoRepayment(loanNo));
    }
    @RequestMapping(value = "selectLoanInfoByMobile",method = RequestMethod.POST)
    public AjaxResult selectLoanInfoByMobile(@RequestParam("mobile") String mobile){
        Assert.notNull(mobile,"参数为空");
        return AjaxResult.success(indexService.selectInfoByLoanNo(mobile));
    }
}
